package com.yixiu.demo.bio.registerserver;


import com.yixiu.demo.bio.registerserver.server.IBuy;
import com.yixiu.demo.bio.registerserver.server.IHello;
import com.yixiu.demo.bio.registerserver.server.ISell;

/**
 * Created by jinhe on 2019/3/21.
 * 客户端
 * 客户端使用代理，调用服务
 */
public class RpcClient {
    // 调用服务
    public static void main(String[] args) {
        String result = "";

        IBuy buy = ProxyFactory.create(IBuy.class,"localhost",8888);
        result =  buy.buy("大米");
        System.out.println(result);

        ISell sell = ProxyFactory.create(ISell.class,"localhost",8888);
        result =  sell.sell("小米");
        System.out.println(result);

        // 注意：两个服务集，只有它们都启动了，才会找到；
        // 在idea中调试，启动一个服务即可

//        IHello hello = ProxyFactory.create(IHello.class,"localhost",6666);
//        result =  hello.sayHello("rpc");
//        System.out.println(result);

    }
}

